//
//  YSGMyopiaButtonParentView.swift
//  EyeVisionForPatients
//
//  Created by PMC on 2021/1/5.
//  Copyright © 2021 QDSG. All rights reserved.
//

import UIKit

class YSGMyopiaButtonParentView: UIView {

    private lazy var reserveView = UINib.loadViewFrom(YSGMyopiaButtonView.self)
    
    private lazy var scanView = UINib.loadViewFrom(YSGMyopiaButtonView.self)
    
    private lazy var recordView = UINib.loadViewFrom(YSGMyopiaButtonView.self)
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        makeUI()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        makeUI()
    }
    
    private func makeUI() {
        addSubview(reserveView)
        addSubview(scanView)
        addSubview(recordView)
        
        reserveView.snp.makeConstraints { (make) in
            make.right.equalTo(scanView.snp.left)
            make.top.bottom.width.equalTo(scanView)
        }
        
        scanView.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.bottom.equalToSuperview()
            make.width.equalTo(54 + 56)
        }
        
        recordView.snp.makeConstraints { (make) in
            make.left.equalTo(scanView.snp.right)
            make.top.bottom.width.equalTo(scanView)
        }
    }
    
    func updateUI(closure: TappedHandle?) {
        reserveView.updateUI(with: .reserve, closure: closure)
        scanView.updateUI(with: .scan, closure: closure)
        recordView.updateUI(with: .record, closure: closure)
    }
}
